`timescale 1ns/100ps
module ifu_tb;
  reg clk, rst;
  reg [1:0] nPC_sel;
  reg [31:0] zero;
  wire [31:0] instruction;
  
  ifu ifu_inst(
  .clk(clk), 
  .rst(rst), 
  .nPC_sel(nPC_sel), 
  .zero(zero), 
  .instruction(instruction[31:0])
  );
  
  initial begin
    clk = 0;
    repeat (30)begin
    #5 clk = ~clk;
    end
  end
  
  initial begin
    rst = 1;
    nPC_sel = 0;
    zero = 0;
    #10 rst = 0;
  end
  
  initial begin
    $readmemh("123.txt", ifu_inst.im);
  end
  
  initial begin
    $dumpfile("ifuwave.vcd");
    $dumpvars(0,ifu);
  end
  
  initial begin
    //顺序执行一条指令
    #20 nPC_sel = 0;
    #20 $display("Instruction: %h", instruction);
    
    //跳转到另一条指令
    #20 nPC_sel = 1;
    #20 ifu_inst.extout = 32'h0000_0010;
    #20 $display("Instruction: %h", instruction);
  end
endmodule